<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>广告管理</title>
    <!-- Le styles -->
    <link href="/common/js/bootstrap-3.0.0/css/bootstrap-united.min.css" rel="stylesheet">
    <style type="text/css">
        body {
            padding: 10px 0;
        }
    </style>
</head>
<body>
<div class="container">
    <#--<form id="form" method="post" class="well form-horizontal">-->
        <#--<fieldset>-->
            <#--<legend>广告管理</legend>-->
            <#--<div class="col-md-6">-->
                <#--<label class="col-md-2 control-label" for="roleName">显示位置</label>-->

                <#--<div class="col-md-10">-->

                    <#--<select id="position_id" name="position_id" class="form-control">-->
                        <#--<option value=""></option>-->
                    <#--<#if adPositionTypeList??>-->
                        <#--<#list adPositionTypeList as positionType>-->
                            <#--<option value="${positionType.getCode()?string}">${positionType.getName()}</option>-->
                        <#--</#list>-->
                    <#--</#if>-->
                    <#--</select>-->
                <#--</div>-->
            <#--</div>-->

            <#--<div class="form-group">-->
                <#--<div class="col-md-12 text-right">-->
                    <#--<button type="button" id="searchBtn" style="width: 80px;" class="btn btn-primary">查询</button>-->
                <#--</div>-->
            <#--</div>-->
        <#--</fieldset>-->
    <#--</form>-->

    <div class="col-md-12 text-right" style="margin:10px 0;">
        <a style="width: 80px;" href="/content/addAdDetailView?position_id=${position_id}&parent_id=${parent_id}" class="btn btn-success">新建</a>
        <button type="button" id="searchBtn" onclick="javascript:history.back(-1);" style="width: 80px;" class="btn btn-success">返回</button>
    </div>

        <table id="resultTable" class="table table-bordered table-hover">
            <thead>
            <tr>
                <th>编号</th>
                <th>类型</th>
                <th>图片</th>
                <th>标题</th>
                <th>状态</th>
                <th>权重</th>
                <th>链接地址</th>
                <th>详情</th>
            </tr>
            </thead>
            <tbody>
            <script type="text/html">
                <tr>
                    <td>{{id}}</td>
                    <td>{{positionId?renderPositionId}}</td>
                    <td><img src="http://img.boyitongcheng.com/{{imgUrl!''}}" width="60px" height="40px"/></td>
                    <td>{{name}}</td>
                    <td>{{status?renderStatus}}</td>
                    <td>{{sort}}</td>
                    <td>{{url}}</td>
                    <td>{{_self_data?renderOperation}}</td>
                </tr>
            </script>
            </tbody>
        </table>
</div>
<#--<div align="center">-->
<#--<#include "../footer.ftl"/>-->
<#--</div>-->
<script type="text/javascript" src="/common/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="/common/js/bootstrap-table.20130913.js"></script>
<script type="text/javascript" src="/common/js/dateformat.js"></script>
<script type="text/javascript" src="/common/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
    $(function () {
        var param = $("#form").serialize();
        var s = $("#resultTable").bsTable({
            url: '/content/getAdDetailList.json?position_id=${position_id}&parent_id=${parent_id}',
            ajaxType: "POST",  //ajax 提交方式 post 或者 get
            pageNo: 1,
            pageNoAlias: 'page',
            pageSize: 10,
            pageSizeAlias: 'pageSize',
            pagingAlign: "right",
            param: param,
            countRoot: "total",
            dataRoot: "list"
        });

        $("#searchBtn").on('click', function () {
            var param = $("#form").serialize();
            s.reload(param);
        });

//        window.onresize = function () {
//            window.top.autoIFrame();
//        }
    });

    function renderStatus(status) {
        if (status == -1) {
            return "删除不显示";
        } else {
            return "启用";
        }
    }

    function renderPositionId(PositionId) {
        if (PositionId == 1) {
            return "首页轮播广告";
        } else if(PositionId == 2) {
            return "列表页顶部";
        } else if(PositionId == 3) {
            return "当季推荐";
        } else if(PositionId == 4) {
            return "经典案例";
        } else if(PositionId == 5) {
            return "首页中间轮播";
        } else if(PositionId == 6) {
            return "首页中间底部";
        } else if(PositionId == 7) {
            return "首页中间右侧";
        } else if(PositionId == 8) {
            return "首页策划师";
        } else if(PositionId == 9) {
            return "首页摄影师";
        } else if(PositionId == 10) {
            return "首页主持人";
        } else if(PositionId == 11) {
            return "首页化妆师";
        } else if(PositionId == 12) {
            return "首页摄像师";
        }else{
            return "其他";
        }
    }

    function renderOperation(row) {
        if (row){
            return '<a style="width: 80px;margin: 3px 1px;" href="/content/deleteAd?id='+row.id+'&parent_id='+${parent_id?string}+'" class="btn btn-info">删除</a>' +
                    '<a style="width: 80px;margin: 3px 1px;" href="/content/editAdDetailView?id='+row.id+'&position_id='+${position_id?string}+'&parent_id='+${parent_id?string}+'" class="btn btn-success">编辑</a>';
        }else{
            return ""
        }
    }

</script>
</body>
</html>